/*******************************************************************************
 * Copyright (c) 2000, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package edu.uts.reekie.designer.implementation.edit;

import org.eclipse.gef.Request;
import org.eclipse.gef.commands.*;
import org.eclipse.gef.requests.*;

import edu.uts.reekie.designer.actions.SetConnectorDirectionAction;
import edu.uts.reekie.designer.edit.AbstractConnectorEditPolicy;
import edu.uts.reekie.designer.implementation.actions.ChangeConnectorHasPortAction;
import edu.uts.reekie.designer.implementation.actions.SetConnectorStyleAction;
import edu.uts.reekie.designer.implementation.model.*;
import edu.uts.reekie.designer.implementation.model.commands.ChangeConnectorHasPortCommand;
import edu.uts.reekie.designer.implementation.model.commands.SetConnectorStyleCommand;
import edu.uts.reekie.designer.model.*;
import edu.uts.reekie.designer.model.commands.*;


public class ConnectorEditPolicy
	extends AbstractConnectorEditPolicy
{
	
	
	public Command getCommand(Request request){
		
		Object t = request.getType();
		
		for (String s: SetConnectorStyleAction.getAllIds()){
			if (s.equals(t)){
				SetConnectorStyleAction.Factory f = SetConnectorStyleAction.all().get(s);
				SetConnectorStyleCommand c = f.createCommand();
				c.setConnector((Connector)this.getHost().getModel());
				return c;
			}
		}
		
		for (String s: ChangeConnectorHasPortAction.getAllIds()){
			if (s.equals(t)){
				ChangeConnectorHasPortAction.Factory f = ChangeConnectorHasPortAction.all().get(s);
				ChangeConnectorHasPortCommand c = f.createCommand();
				c.setConnector((Connector)this.getHost().getModel());
				return c;
			}
		}
		
		return super.getCommand(request);
		
	}

}
